package com.qf.controller;

import com.qf.entity.Order;
import com.qf.service.OrderService;
import com.qf.service.impl.OrderServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author 10202
 * @version V1.0
 * @Project xiaomi
 * @Package ${PACKAGE_NAME}
 * @Date 2023/4/17 22:58
 */
@WebServlet(name = "ChangeStatusServlet",urlPatterns = "/changeStatus")
public class ChangeStatusServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String oid = request.getParameter("oid");
        if(oid==null){
            return;
        }
        try {
            OrderService orderService=new OrderServiceImpl();
            Order order = orderService.queryOrderByOid(oid);
            order.setStatus("4");
            orderService.updateOrderByOrder(order);
        } catch (Exception e) {
            e.printStackTrace();
        }
       response.sendRedirect(request.getContextPath()+"/getOrderList?method=orderList");

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
